package keter.combofs;

import keter.combofs.api.ComboFs;
import keter.combofs.api.adapters.ComboFsAdapter;
import keter.combofs.id.IdMaker;
import keter.combofs.id.impl.SequenceIdImpl;
import keter.combofs.path.PathMaker;
import keter.combofs.path.impl.PathMakerFSImpl;
import keter.combofs.persist.ComboFileDao;
import keter.combofs.persist.impl.ComboFileDaoFSImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 初始化配置
 */
@Configuration
public class ComboFSAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(ComboFSAutoConfiguration.class);


    @Bean
    @ConditionalOnMissingBean
    public ComboFs initComboFs() {
        logger.info("使用操作系统文件系统（默认策略）...");
        return new ComboFsAdapter();
    }

    @Bean
    @ConditionalOnMissingBean
    public PathMaker initPath() {
        return new PathMakerFSImpl();
    }

    @Bean
    @ConditionalOnMissingBean
    public ComboFileDao initDao() {
        return new ComboFileDaoFSImpl();
    }

    @Bean
    @ConditionalOnMissingBean
    public IdMaker initSequence() {
        logger.info("初始化默认的ID生成策略...");
        return new SequenceIdImpl(1);
    }
}
